// currying 也叫不完全函数

function add() {
    var tmpSlice = [].slice,
        params = tmpSlice.apply(arguments);

    function currying() {
        var arr = tmpSlice.call(arguments)
        params = params.concat(arr);
        return currying
    }
    currying.toString = function () {
        var result = 0;
        params.forEach(element => {
            result += element;
        });
        return result
    };
    return currying;
}

console(add(3, 5));
console(add(3)(5));
console(add(3, 5)(6));